//
//  MainViewController.m
//  MoGuRadio
//
//  Created by dlios on 15-7-3.
//  Copyright (c) 2015年 mogu.com 蘑菇科技. All rights reserved.
//

#import "MainViewController.h"

@interface MainViewController ()

@property (nonatomic, retain) UIButton *sinaButton;

@end

@implementation MainViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    
    
    
}

- (void)sina
{
    self.sinaButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    self.sinaButton.frame = CGRectMake(20, 100, 50, 50);
    self.sinaButton.backgroundColor = [UIColor blackColor];
    [self.sinaButton addTarget:self action:@selector(sinaBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.sinaButton];
}

//微博登陆

- (void)sinaBtnClick:(UIButton *)btn
{
    NSString *platformName = [UMSocialSnsPlatformManager getSnsPlatformString:UMSocialSnsTypeSina];
    
    UMSocialSnsPlatform *snsPlatform = [UMSocialSnsPlatformManager getSocialPlatformWithName:UMShareToSina];
    
    snsPlatform.loginClickHandler(self,[UMSocialControllerService defaultControllerService],YES,^(UMSocialResponseEntity *response){
        
        NSLog(@"response is %@",response);
        
        if (response.responseCode == UMSResponseCodeSuccess) {
            
            UMSocialAccountEntity *snsAccount = [[UMSocialAccountManager socialAccountDictionary] valueForKey:platformName];
            
            NSLog(@"=========%@",snsAccount.accessToken);
            
        }
        
    });
}


//回调方法

-(void)didFinishGetUMSocialDataInViewController:(UMSocialResponseEntity *)response

{
    
    if (response.viewControllerType == UMSViewControllerOauth) {
        
        NSLog(@"didFinishOauthAndGetAccount response is %@",response);
        
    }
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
